<%-- 
    Document   : compose
    Created on : Mar 6, 2014, 11:35:59 AM
    Author     : Jordan,Theodoro
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<c:if test="${sessionScope.username == NULL}">
    <c:redirect url="http://webtek.org/Bonix/index.php"/>
</c:if>
<c:set var="startFromRecNo" value="0"/>
<c:if test="${param.start != null}">
    <c:set var="startFromRecNo" value="${param.start}"/>
</c:if>

<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>

<c:set scope="request" var="title" value="Message"/>
<sql:query var="customers">
    SELECT distinct sender
    FROM messages
    WHERE receiver ='${sessionScope.username}'
</sql:query>
<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"/>

    <body>
        <jsp:include page="banner.jsp"/>

        <div class="row">
            <div class="container_header">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel panel-info">

                            <div class="panel-heading">
                                <ul class="navClient navClient-pills">


                                    <c:url var="messagesURL" value="messages.jsp" />
                                    <li><a href="${messagesURL}"> Message Inbox </a></li>

                                    <c:url var="composeURL" value="compose.jsp" />
                                    <li><a href="${composeURL}"> Compose Message </a></li>

                                    <c:url var="sentItemsURL" value="sentItems.jsp" />
                                    <li><a href="${sentItemsURL}"> Sent Item </a></li>
                                </ul>
                            </div>

                            <div class="panel-body">
                                ${param.serviceProvider}
                                <br><hr><br>
                                <form action='sendMessage.jsp' method='post'>
                                    <label>Recipient:</label>
                                    <select name="cust" style="width:180px;height:30px">
                                        <c:if test="${param.recepient != null}">
                                            <option style="width:180px;height:30px">${param.recepient}</option>
                                        </c:if>
                                        <c:forEach var="customer" items="${customers.rows}">
                                            <option style="width:180px;height:30px">${customer.sender}</option>
                                        </c:forEach>
                                    </select>
                                    <br>
                                    <br>
                                    <label>Message:</label>
                                    <textarea class="form-control" name="message" rows="10" cols="50" ></textarea>
                                    <br>
                                    <button type="submit" class="btn btn-primary">SEND MESSAGE</button>
                                </form>

                            </div><!-- END panel-body -->

                        </div><!-- END panel-info -->
                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->
        
        <jsp:include page="footer.jsp"/>
        
    </body>
</html>
